package com.wwj.study.interview.chapter3;

public class ThreadTest {

    private static int i;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread() {
            @Override
            public void run() {
                //当前线程是否被中断
                while (!Thread.currentThread().isInterrupted()) {
                    i++;
                }
                System.out.println("i=" + i);
            }
        };
        thread.start();
        Thread.sleep(1000);
        thread.interrupt();
    }
}
